package edu.sctu.xialei.june.day20150614one.iterator.test;

import java.util.HashMap;
import java.util.Iterator;

/**
 * Created by Administrator on 2015/6/14.
 */

/**
*Map and Iterator practice Class
 */
public class IteratorPracticeTwo {

    public void test() {
        HashMap<Integer, String> map = new HashMap<Integer, String>();

        map.put(19, "one");
        map.put(18, "two");
        map.put(20, "three");
        map.put(17, "four");
        map.put(20, "five");

        Iterator iteratorOne = map.entrySet().iterator();

        while (iteratorOne.hasNext()) {
            System.out.println(iteratorOne.next());
        }

        Iterator iteratorTwo = map.keySet().iterator();

        while (iteratorTwo.hasNext()) {
            System.out.println(iteratorTwo.next());
        }

        Iterator iteratorThree = map.values().iterator();

        while (iteratorThree.hasNext()) {
            System.out.println(iteratorThree.next());
        }
    }
}

